package com.example.soss.entity;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一响应结果
 */

@Data
@NoArgsConstructor
public class Result {
    private int respCode;
    private String respMsg;
    private String token;




    public static Result success(String respMsg) {
        Result result = new Result();
        result.setRespCode(200);
        result.setRespMsg(respMsg);
        return result;
    }

    public static Result success(ResultEnum resultEnum, String token) {
        return new Result(resultEnum, token);
    }


    public static Result failure(int respCode, String respMsg) {
        Result result = new Result();
        result.setRespCode(respCode);
        result.setRespMsg(respMsg);
        return result;
    }

    public static Result failure(String respMsg) {
        Result result = new Result();
        result.setRespMsg(respMsg);
        return result;
    }



    public Result(ResultEnum resultEnum) {
        this.respCode = resultEnum.code();
        this.respMsg = resultEnum.msg();
    }

    public Result(ResultEnum resultEnum, String token) {
        this.respCode = resultEnum.code();
        this.respMsg = resultEnum.msg();
        this.token = token;
    }


    public static Result failure(ResultEnum resultEnum) {
        return new Result(resultEnum);
    }
    public static Result success(ResultEnum resultEnum) {
        return new Result(resultEnum);
    }


}